//
//  UIImage+clearImage.m
//  TravelGuideMdd
//
//  Created by 陈曦 on 13-11-9.
//  Copyright (c) 2013年 mafengwo.com. All rights reserved.
//

#import "UIImage+clearImage.h"

@implementation UIImage(clearImage)

+ (UIImage*)imageWithColor:(UIColor*)aColor
                      size:(CGSize)size
{
    UIGraphicsBeginImageContextWithOptions(size, NO, [UIScreen mainScreen].scale);
    if (aColor && aColor != [UIColor clearColor])
    {
        [aColor set];
        CGContextFillRect(UIGraphicsGetCurrentContext(), CGRectMake(0,0,size.width,size.height));
    }
    UIImage *newimage = UIGraphicsGetImageFromCurrentImageContext();
    UIGraphicsEndImageContext();
    return newimage;
}

+ (UIImage*)clearImageWithSize:(CGSize)size
{
    return [self imageWithColor:nil size:size];
}

+ (UIImage*)imageWithColor:(UIColor *)aColor
{
    return [self imageWithColor:aColor size:(CGSize){1,1}];
}

@end
